package com.tajiang.business.common.retrofit;

import com.tajiang.business.common.application.TJApp;
import com.tajiang.business.common.constant.TJCst;
import com.tajiang.business.common.retrofit.cookieJar.ClearableCookieJar;
import com.tajiang.business.common.retrofit.cookieJar.PersistentCookieJar;
import com.tajiang.business.common.retrofit.cookieJar.cache.SetCookieCache;
import com.tajiang.business.common.retrofit.cookieJar.persistence.SharedPrefsCookiePersistor;
import com.tajiang.business.common.retrofit.ssl.TJSSLUtil;
import com.tajiang.business.common.utils.NetWorkUtils;

import java.io.IOException;

import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;

import okhttp3.CertificatePinner;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2016/6/6.
 */
public class TJRetrofit {

    private static RetrofitService service;

    public static RetrofitService createRetrofitService() {
        if(service == null) {
            synchronized (TJRetrofit.class) {
                Retrofit retrofit = new Retrofit.Builder()
                        .baseUrl(TJCst.BASE_URL)
                        .client(TJApp.getInstance().getOkHttpClient())
                        .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                        .addConverterFactory(GsonConverterFactory.create())
                        .build();
                service = retrofit.create(RetrofitService.class);
            }
        }
        return service;
    }

}
